Use modern CMake's target_* functions to set compiler flags/features#11
Use modern CMake's target_* functions to set compiler flags/features#11lrvdijk wants to merge 10 commits intopmelsted:masterfrom
Conversation
This is more modern CMake, and makes it easier to include Bifrost in other CMake projects (as library for example). One of the big benefits of the new target_* API is that compiler options like -march=native now get propogated to any executable linking to bifrost_static of bifrost_dynamic.
|
Hi there, First of all, thank you for your contribution! I am very glad that you like Bifrost so let us know if we can do anything else to help integrate Bifrost into your own project. Thank you again for your work! Best, |
Should support single and multiple configuration generators. Profiling currently only supported on GCC.
|
I've updated the cmake scripts with improved support for profiling. Setting Following guidelines from: |
|
Hey @lrvdijk, Thank you again for your contribution and your efforts on PyBifrost. It took me some time to get back to you on this PR because I'm developing Bifrost on my free time nowadays. I have a couple of questions regarding your PR if you don't mind:
Thank you for your time. |
- Make sure include directory for bifrost_dynamic is correct when installing - Use the right minimum cmake version - Give error when trying to enable profiling on a compiler other than GCC
|
Thanks for your time! I've updated the CMakeLists.txt a bit more, which should address most of your points! However, I noticed that Debug mode is not gone, as can be seen on this line: I append |
target_link_options was added in 3.13
Hi all,
Thank you for this great piece of software, it's blazingly fast and memory efficient! The past few days I have been playing around a bit with the API, and trying to integrate it in one of my projects.
In my own C++ projects, I usually include third party depencies as git submodules in a
vendor/directory. Then in my own CMakeLists.txt files, I can calladd_subdirectoryon those third party dependencies, and all their targets will be available in my own CMakeList.txt too (makes it easy to link them, and configure all include directories etc.)I did the same thing with Bifrost, however, one of my executables was segfaulting, even though it was a very tiny toy example that hardly did anything. After some debugging, I found that my executable missed the
-march=nativecompiler flag, and therefore the instruction sets of bifrost_static and my executable mismatched, resulting in stack corruption.The new target_* based API introduced in CMake 3 is supposed to better deal with these kinds of situations. In this pull request I changed the CMakeLists.txt a bit to make use of this new API. This makes it easier to include Bifrost in other (CMake based) projects, by simply including Bifrost using
add_directoryand linking tobifrost_staticorbifrost_dynamic, and ensures that the required compiler flags get propagated to the linked executables too.I'll admit, I've only minimally changed it, until it fixed my problem 😬 I've not checked the options you seem to use for profiling etc. Anyway hope it's a useful starting point. I've found this guide on modern Cmake helpful: https://cliutils.gitlab.io/modern-cmake/